//
//  Feature.hpp
//  markerARLib
//
//  Created by CvidKal on 16/4/14.
//  Copyright © 2016年 CvidKal. All rights reserved.
//

#ifndef Feature_hpp
#define Feature_hpp

#include <stdio.h>
#include <Eigen/Dense>
#include "Patch.hpp"
#include "MapPoint.hpp"
namespace markerAR
{
    
class Frame;
class Feature
{
public:
    enum FeatureType
    {
        PATCH,
        BINARY
    };
    Feature()
    {
        _pos.x() = 0;
        _pos.y() = 0;
        point3D = nullptr;
        pointXYZ = nullptr;
        patch_with_border_ = nullptr;
    }
    Feature(float x,float y);
    Feature(float x,float y,Frame*frame);
    
    ~Feature(){if(patch_with_border_!= nullptr) delete patch_with_border_;};
    bool& isBad(){return bad;}
    Feature(const Feature&) = delete;
    Eigen::Vector2d _pos;
    Patch* patch_with_border_;
    cv::Point3f * point3D;//opencv interface will be remove in the futre
    cv::Mat desp;//descriptorfeature
    Frame* frame;
    float sigma;
    float invSigma2(){return 1.f/pow(sigma,2);};
    MapPoint* pointXYZ;
    Eigen::Vector3f normal;
    Eigen::Vector3d f;//unit-bearing vector of this feature
    bool inlier;
private:
    bool bad;//flag is set due to out of range or some other reason
    FeatureType type;
};


}

#endif /* Feature_hpp */
